<#include "../../base.ftl"/>

<#macro title>
物流交易系统
</#macro>
<#macro cssfile>
</#macro>
<#macro scriptfile>
</#macro>
<#macro jsscript>
$(function(){
	$("#weight").removeAttr().val("");
	$("#volume").removeAttr().val("");
	$("#name").removeAttr().val("");
	$("#price").removeAttr().val("");
	$("#remark").removeAttr().val("");
	$("#arriveTime").removeAttr().val("");
})
  function checPrice(){
	var price=$("#price").val();
	if(price.length==0){
		$('#price1').html('运费不能为空');
		return false;
	}else{
		$('#price1').html('');
		return true;
	}
	
}

function checkWeight(){
	var weight=$("#weight").val();
	if(weight.length==0){
		$('#weight1').html('重量不能为空');
	 return false;
	}else{
		$('#weight1').html('吨');
		return true;
	}
	
}
  
 function checkVolumn(){
	 var volume=$("#volume").val();
	 if(volume.length==0){
		 $("#volume1").html('体积不能为空');
		 return false;
	 }else{
		 $("#volume1").html('m³');
		 return true;

	 }
	 
 }
 
 function checkName(){
	 var name=$("#name").val();
	 if(name.length==0){
		 $("#name1").html('品名不能为空');
		 return false;
	 }else{
		 $("#name1").html('');
		 return true;
	 }
	 
 }
 

 function checkArriveTime(){
	 var arriveTime=$('#arriveTime').val();
	 if(arriveTime.length==0){
		 $("#arriveTime1").html("时间不能为空");
	    return false;
	 }else{
		 $("#arriveTime1").html('');
	    return true;
	 }
	 
	 
	 
 }
    addressInit('cmbProvince', 'cmbCity', 'cmbArea', '北京', '市辖区', '东城区');
	addressInit('Select1', 'Select2', 'Select3');
	
	
	
	$('#submit').click(function(){
	   
       var transport=$("#transport").val();
       var load=$("#load").val();
       var qualification=$("#qualification").val();
       var material=$("#material").val();
       var price=$("#price").val();
       var weight=$("#weight").val();
       var volume=$("#volume").val();
       var name=$("#name").val();
       var arriveTime=$("#arriveTime").val();
       var cmbProvince=$("#cmbProvince").val();
       var cmbCity=$("#cmbCity").val();
       var cmbArea=$("#cmbArea").val();
       var Select1=$("#Select1").val();
       var Select2=$("#Select2").val();
       var Select3=$("#Select3").val();
       var remark=$("#remark").val();
       if(weight.length==0||price.length==0||arriveTime.length==0||volume.length==0||name.length==0){
    	   alert("请完整信息");
    	   return false
       }else{
       $.ajax({
              url: '${request.contextPath}/operator/tlt/TltLogisticsDemand/operator.html', 
    	      type:'post',
              data:{"oper":"add","transportMode":transport,'loadMode':load,'cargoType':qualification,'packagingMaterial':material,'cargoName':name,'cargoWeight':weight,'cargoVolume':volume,'dispatchAddress':cmbProvince+cmbCity+cmbArea,'arriveDate':arriveTime,'amount':price,'destination':Select1+Select2+Select3,'remark':remark},
              dataType : 'json',
              success:function(result){
        	      alert(result.message);
        	      $("#weight").removeAttr().val("");
        	  	$("#volume").removeAttr().val("");
        	  	$("#name").removeAttr().val("");
        	  	$("#price").removeAttr().val("");
        	  	$("#remark").removeAttr().val("");
        	  	$("#arriveTime").removeAttr().val("");
        	  	window.location.href="index.html";

               },
             'error':function(xhr,e1,e2){
    	             alert("操作有误");
               }
           });
       
       }
    
	})
</#macro>
<#macro main>
<div class="span11" style="margin-top: 20px;margin-left:70px">
        <legend class="" align="center">物流需求信息---新增信息</legend>
		<table class="table table-bordered">
              <tbody>
                <tr>
                  <td>
                  		<div class="control-group form-horizontal">
                    	<label class="control-label">运输方式</label>
                    <div class="controls">
                        <select class="input-xlarge" style="width:285px;" id="transport">
                            <option>水运</option>
                            <option>陆运</option>
                            <option>空运</option>
                        </select>
                    </div>
                		</div>
                  </td>
                  <td>
                  		<div class="control-group form-horizontal">
                    	<label class="control-label">装载方式</label>
                    <div class="controls">
                        <select class="input-xlarge" style="width:285px;" id="load">
                            <option>集装箱</option>
                            <option>散货</option>
                        </select>
                    </div>
                		</div>
                  </td>
                </tr>
                <tr>
                  <td>
                  		<div class="control-group form-horizontal">
                    	<label class="control-label">货物类别</label>
                    <div class="controls">
                        <select class="input-xlarge" style="width:285px;" id="qualification">
                            <option>非危品</option>
                            <option>危险品</option>
                            <option>冷货</option>
                        </select>
                    </div>
                		</div>
                  </td>
                  <td>
                  		<div class="control-group form-horizontal">
                    	<!-- Text input-->
                        <label class="control-label" for="input01">包装材质</label>
                        <div class="controls">
                        <select class="input-xlarge" style="width:285px;" id="material">
                            <option>袋</option>
                            <option>托</option>
                            <option>箱</option>
                        </select>
                        </div>
                		</div>
                  </td>
                </tr>
                <tr>
                <td>
                  		<div class="control-group form-horizontal">
                    	<label class="control-label">品名</label>
                    <div class="controls">
                            <input id="name" placeholder="品名" class="input-xlarge" type="text"  onblur="checkName();"/>
                            <span id="name1" style="color:red"></span>
                        </div>
                		</div>
                  </td>
                  <td>
                  		<div class="control-group form-horizontal">
                    	<!-- Text input-->
                        <label class="control-label" for="input01">重量</label>
                        <div class="controls">
                            <input id="weight" placeholder="重量" class="input-xlarge" type="text" onkeyup="value=value.replace(/[^\d.]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d.]/g,''))" onblur="checkWeight();"/>
                            <span id="weight1" style="color:red"><font color="#ff0000" size="3">&nbsp;&nbsp;吨</font></span>
                        </div>
                		</div>
                  </td>
                </tr>
                
                <tr>
                 <td>
                  		<div class="control-group form-horizontal">
                    	<!-- Text input-->
                        <label class="control-label" for="input01">运费</label>
                        <div class="controls">
                            <input id="price" placeholder="运费" class="input-xlarge" type="text" onkeyup="value=value.replace(/[^\d.]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d.]/g,''))" onblur="checPrice();"/>
                            <span id="price1" style="color:red"></span>
                        </div>
                		</div>
                  </td>
                  <td>
                  		<div class="control-group form-horizontal">
                    	<label class="control-label">起运港</label>
                    <div class="controls">
                                                                            省&nbsp;&nbsp;
                         <select name="zy" class="span3" id="cmbProvince">
                                       </select>
                                                                         &nbsp;&nbsp;市
                        <select name="zy" class="span3" id="cmbCity">
                                       </select>&nbsp;&nbsp;区
                       <select name="zy" class="span3" id="cmbArea">
                                       </select>
                    </div>
                    
                		</div>
                  </td>
                </tr>
                <tr>
                <td>
                  		<div class="control-group form-horizontal">
                    	<!-- Text input-->
                        <label class="control-label" for="input01">要求到达时间</label>
                        <div class="controls">
                            <input id="arriveTime" class="Wdate" type="text" onFocus="WdatePicker({minDate:'%y-%M-{%d}'})" onblur="checkArriveTime();"/>
                               <span id="arriveTime1" style="color:red"></span>
                               </div>
                        </div>
                  </td>
                
                  <td>
                  		<div class="control-group form-horizontal">
                    	<label class="control-label">目的港</label>
                    <div class="controls">
                                                                            省&nbsp;&nbsp;
                         <select name="zy" class="span3" id="Select1">
                                       </select>
                                                                         &nbsp;&nbsp;市
                        <select name="zy" class="span3" id="Select2">
                                       </select>
                                                                       &nbsp;&nbsp;区
                       <select name="zy" class="span3" id="Select3">
                                       </select>
                    </div>
                		</div>
                  </td>
                </tr>
                <tr>
                <td>
                  		<div class="control-group form-horizontal">
                    	<!-- Text input-->
                        <label class="control-label" for="input01">体积</label>
                        <div class="controls">
                            <input id="volume" placeholder="体积" class="input-xlarge" type="text" onkeyup="value=value.replace(/[^\d.]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d.]/g,''))" onblur="checkVolumn();"/>
                            <span id="volume1" style="color:red"><font color="#ff0000" size="3">&nbsp;&nbsp;m³</font></span>
                        </div>
                		</div>
                  </td>
                  <td>
                  		<div class="control-group form-horizontal">
                    	<!-- Textarea-->
                        <label class="control-label" for="input01">备注</label>
                        <div class="controls">
                        <div class="textarea">
                            <textarea type="" class="" style="width:270px;" id="remark"> </textarea>
                        </div>
                    </div>
                		</div>
                  </td>
                </tr>
                <tr>
                  <td colspan="2">
                  		<button class="btn btn-large btn-block btn-primary" type="button" id="submit">提交</button>
                  </td>
                </tr>
              </tbody>
            </table>

        </div><!--/span-->
</#macro>